package com.chen.blue.banner;

import cn.hutool.core.thread.ThreadUtil;
import com.chen.blue.listener.SystemConnect;
import com.chen.blue.utils.SpringUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

import java.net.InetAddress;
import java.util.concurrent.TimeUnit;

/**
 * Created By CLT On 2024/6/23.
 */
@SuppressWarnings("all")
@Slf4j
@Component
public class SystemInfoRunner implements ApplicationRunner {


    @Override
    public void run(ApplicationArguments args) throws Exception {

        ThreadUtil.execute(() -> {

            try {
                new SystemConnect().vaildContect();
                TimeUnit.SECONDS.sleep(1);
                log.info("\n------------------------------------------------------------------\n\t" +
                                "{}启动成功!  ๑◔‿◔๑\n\t" +
                                "项目访问地址:\thttp://{}:{}\n\t" +
                                "接口文档地址:\thttp://{}:{}/doc.html\n" +
                                "------------------------------------------------------------------",
                        SpringUtil.getProperty("spring.application.name"),
                        InetAddress.getLocalHost().getHostAddress(),
                        SpringUtil.getProperty("server.port"),
                        InetAddress.getLocalHost().getHostAddress(),
                        SpringUtil.getProperty("server.port"));
            } catch (Exception e) {
                e.printStackTrace();
            }

        });

    }

}
